package demoxsgl_300.com.gouwu1500.zhi;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import demoxsgl_300.com.gouwu1500.R;
import demoxsgl_300.com.gouwu1500.http.API;
import demoxsgl_300.com.gouwu1500.http.Okhttp;

/**
 * 反馈
 */
public class FaKuiActivity extends Activity {

    @BindView(R.id.fanhui)
    TextView fanhui;
    @BindView(R.id.textView5)
    TextView textView5;
    @BindView(R.id.imageView2)
    ImageView imageView2;
    @BindView(R.id.imageView3)
    ImageView imageView3;
    @BindView(R.id.textView7)
    TextView textView7;
    @BindView(R.id.login_phone)
    EditText loginPhone;
    @BindView(R.id.wushangshu)
    ImageView wushangshu;
    @BindView(R.id.queding)
    ImageView queding;
    @BindView(R.id.next)
    Button next;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fakui);
        ButterKnife.bind(this);

    }

    @OnClick({R.id.fanhui, R.id.next, R.id.wushangshu, R.id.queding})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.wushangshu:
                wushangshu.setImageDrawable(getResources().getDrawable(R.drawable.zantong));
                queding.setImageDrawable(getResources().getDrawable(R.drawable.fan_q));
                break;
            case R.id.queding:
                wushangshu.setImageDrawable(getResources().getDrawable(R.drawable.zan_q));
                queding.setImageDrawable(getResources().getDrawable(R.drawable.fandui));
                break;
            case R.id.fanhui:
                finish();
                break;
            case R.id.next:


                API.submission(loginPhone.getText().toString(), new Okhttp.Objectcallback() {
                    @Override
                    public void onsuccess(String st) {
                        Log.e("11111", "xx" + st);
                        Log.e("111", "xx:" + st);
                        if (st.equals("unsunccess")) {
                            Toast.makeText(FaKuiActivity.this, "反馈失败!", Toast.LENGTH_SHORT).show();
                        } else {
                            Toast.makeText(FaKuiActivity.this, "反馈成功!", Toast.LENGTH_SHORT).show();
                            finish();
                        }
                    }

                    @Override
                    public void onFalia(int code, String errst) {
                        Toast.makeText(FaKuiActivity.this, "网络错误" + errst, Toast.LENGTH_SHORT).show();
                        Log.e("11111", "xx" + errst);
                    }
                });
                break;
        }
    }
}
